using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace GeorgeHerolyants.Converters
{
    internal class FileConverter : IConverter
    {

        public FileConverter ( )
        {
        }

        public FileConverter ( string inputPath, string outputPath )
        {
            InputPath = inputPath;
            OutputPath = outputPath;
        }

        private string _inputPath;

        public string InputPath
        {
            get { return _inputPath; }
            set { _inputPath = value; }
        }

        private string _outputPath;

        public string OutputPath
        {
            get { return _outputPath; }
            set { _outputPath = value; }
        }

        public string SearchPattern
        {
            get { return string.Empty; }
            set { }
        }

        public bool SearchRecursive
        {
            get { return false; }
            set { }
        }

        public void Convert ( )
        {
            StreamReader reader = new StreamReader(
               new FileStream( InputPath, FileMode.Open, FileAccess.Read ),
               Encoding.GetEncoding( 1251 ) );
            string buf = reader.ReadToEnd();
            reader.Close();

            StreamWriter writer = new StreamWriter(
                new FileStream( OutputPath, FileMode.Create, FileAccess.Write ),
                Encoding.UTF8 );
            writer.Write( buf );
            writer.Close();
        }
    }
}
